package request;

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.IOException;

/**
 * request获取请求行数据
 */
@WebServlet("/request_demo1")
public class request_demo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取请求方式
        System.out.println(request.getMethod());

        //2.获取虚拟目录
        System.out.println(request.getContextPath());

        //3.获取servlet路径
        System.out.println(request.getServletPath());

        //4.获取请求参数
        System.out.println(request.getQueryString());

        //5.获取URI
        System.out.println(request.getRequestURI());
        System.out.println(request.getRequestURL());

        //6.获取协议版本
        System.out.println(request.getProtocol());

        //7.获取客户机id
        System.out.println(request.getRemoteAddr());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
